const Koa = require("koa");

const app = new Koa();

app.use((ctx, next) => {
  if (ctx.request.url === "/login") {
    if (ctx.request.method === "GET") {
      ctx.response.body = "登录成功";
    }
  } else {
    ctx.response.body = "其他请求";
  }
});

app.listen(8000, () => {
  console.log("Koa注册中间件服务器启动成功");
});
